<template>
  <div class="app-container">
    <label class="title" style="font-size: 20px;color: rgba(0,0,0,.85);font-weight: 600;line-height: 32px">考生考试验证</label>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="准考号" prop="zkh">
        <el-input
          v-model="queryParams.zkh"
          placeholder="准考号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="考试项目" prop="examId">
        <el-select v-model="queryParams.examId" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in projectIdList"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="verifyList">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{scope.$index+(queryParams.pageNo-1)*queryParams.pageSize+1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="准考号" align="center" prop="zkz" />
      <el-table-column label="姓名" align="center" prop="ksName" />
      <el-table-column label="性别" align="center" prop="gender">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender"/>
        </template>
      </el-table-column>
      <el-table-column label="考试项目" align="center" prop="examName" />
      <el-table-column label="验证方式" align="center" prop="methods" />
      <el-table-column label="阈值" align="center" prop="threshold" />
      <el-table-column label="分值" align="center" prop="score" />
      <el-table-column label="验证时间" align="center" prop="gmtVerified" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmtVerified, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
            v-hasPermi="['business:examVerifies:detail']"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 考生身份验证详情 -->
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
      <el-form :inline="true" ref="form" :model="form" label-width="80px">
        <table>
          <tr>
            <td>
              <el-form-item label="准考号" prop="zkz">
                <el-input v-model="form.zkz" :disabled="disabled" />
              </el-form-item>
            </td>
            <td>
              <el-form-item label="姓 名" prop="ksName">
                <el-input v-model="form.ksName" :disabled="disabled" />
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="性 别" prop="gender">
                <el-select v-model="form.gender" placeholder="请选择" clearable size="small" class="selectWidth" :disabled="disabled">
                  <el-option
                    v-for="dict in dict.type.sys_user_sex"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </td>
            <td>
              <el-form-item label="项目名称" prop="examName">
                <el-input v-model="form.examName" :disabled="disabled" />
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="验证方式" prop="methods">
                <el-select v-model="form.methods" placeholder="请选择" clearable size="small" class="selectWidth" :disabled="disabled">
                  <el-option
                    v-for="dict in dict.type.examVerifyMethods"
                    :key="dict.value"
                    :label="dict.remark"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </td>
            <td>
              <el-form-item label="阈 值" prop="threshold">
                <el-input v-model="form.threshold" :disabled="disabled" />
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="分 值" prop="score">
                <el-input v-model="form.score" :disabled="disabled" />
              </el-form-item>
            </td>
            <td>
              <el-form-item label="验证时间" prop="gmtVerified">
                <el-date-picker clearable size="small"
                                v-model="form.gmtVerified"
                                type="datetime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                :disabled="disabled">
                </el-date-picker>
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="现场照片" prop="picture">
                <img style="width: 160px; height: 160px" :src=form.remark v-if="form.pictureUrl"/>
                <img style="width: 160px; height: 160px" :src="'data:image/png;base64,'+form.picture" v-else/>
              </el-form-item>
            </td>
            <td>
              <el-form-item label="准考证照" prop="zp">
                <img style="width: 160px; height: 160px" :src="form.zp"></img>
              </el-form-item>
            </td>
          </tr>
        </table>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  import { getVerify, listVerify } from '@/api/business/verify/verify'
  import { examProjectsList } from '@/api/business/candidate/candidate'

  export default {
        name: "Verify",
        dicts: ['sys_user_sex','examVerifyMethods'],
        data() {
            return {
                // 遮罩层
                loading: true,
                // 导出遮罩层
                exportLoading: false,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 考生考试验证表格数据
                verifyList: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,

                disabled:true,
                // 查询参数
                queryParams: {
                    pageNo: 1,
                    pageSize: 10,
                    zkh: null,
                    examId:null,
                },
                // 表单参数
                form: {},
                projectIdList: [],
            };
        },
        created() {
            this.getList();
            examProjectsList().then(response => {
                this.projectIdList = response.data;
            })
        },
        methods: {
            /** 查询考生考试验证列表 */
            getList() {
                this.loading = true;
                listVerify(this.queryParams).then(response => {
                    this.verifyList = response.data.records;
                    this.total = response.data.totalCount;
                    this.loading = false;
                });
            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
                    zkz:null,
                    ksName: null,
                    gender:null,
                    examId: null,
                    examName: null,
                    methods: null,
                    threshold:null,
                    score:null,
                    gmtVerified: null,
                    id: null,
                    picture: null,
                    zp:null
                };
                this.resetForm("form");
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNo = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },
            /** 查看按钮操作 */
            handleDetail(row) {
                this.reset();
                const id = row.id || this.ids
                getVerify(id).then(response => {
                    this.form = response.data;
                    this.form.gender = response.data.gender+'';
                    this.open = true;
                    this.title = "考生身份验证详情";
                });
            }
        }
    };
</script>
